package it.polimi.swKnights.SWIMv2.ejb.entityBeans;

import java.io.Serializable;
import javax.persistence.*;

/**
 * Entity implementation class for Entity: Feedback
 * 
 */
@Entity
@IdClass(FeedbackPk.class)
public class Feedback implements Serializable
{
	@Id
	private long id;
	
	@Id
	@Column(name = "gotBy", insertable = false, updatable = false)
	private String gotBy;
	
	
	@ManyToOne
	@JoinColumn(name = "gotBy", insertable = false, updatable = false)
	private RegisteredUser gotByUser;
	
	@ManyToOne
	private RegisteredUser leftBy;
	
	private int rank;
	
	private String text;
	
	private boolean disputed;
	
	
	/*
	 * Serial Version ID
	 */
	
	private static final long serialVersionUID = 1L;

	/*
	 * Constructors
	 */
	
	public Feedback()
	{
		//super();
	}
	
	public Feedback(RegisteredUser gotBy, int rank)
	{
		//this();
		this.gotBy = gotBy.getUserName();
		this.rank = rank;
		this.setDisputed(false);
	}
	
	public Feedback(long l, RegisteredUser gotBy, int rank, RegisteredUser leftBy)
	{
		this.id = l;
		this.gotBy = gotBy.getUserName();
		this.rank = rank;
		this.leftBy = leftBy;
	}
	
	
	/*
	 * Getters and setters
	 */
	
	public RegisteredUser getLeftBy()
	{
		return this.leftBy;
	}
	 
	
	public void setLeftBy(RegisteredUser leftBy)
	{
		this.leftBy = leftBy;
	}



	public int getRank()
	{
		return rank;
	}

	public void setRank(int rank)
	{
		this.rank = rank;
	}

	public String getText()
	{
		return text;
	}

	public boolean getDisputed()
	{
		return this.disputed;
	}
	
	public String getDisputedAsStringLowCase()
	{
		return this.disputed == true ?  "true" : "false";
	}
	
	
	public void setText(String text)
	{
		this.text = text;
	}

	public long getId()
	{
		return this.id;
	}
	
	public boolean isDisputed() {
		return disputed;
	}

	public void setDisputed(boolean disputed) {
		this.disputed = disputed;
	}

	public String getGotByUsername()
	{
		return this.gotBy;
	}


}
